using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace MicroMsg.UI.UserContrl
{
	public class VoiceInputButton : Button
	{
		public enum focusLocate
		{
			inButton = 1,
			inCancel,
			inOther
		}
		public delegate void VoiceButtonFocusFieldChange(object sender, FocusFieldArgs focusFieldArgs_0);
		private Point buttonfieldStart = new Point(0.0, 0.0);
		private double buttonWidth = 267.0;
		private double buttonHeight = 71.0;
		private Point cancelFieldStart = new Point(169.0, -449.0);
		private double cancelWidth = 211.0;
		private double cancelHeight = 272.0;
		private Point deltaPoint = default(Point);
		public VoiceInputButton.focusLocate nowLocate = VoiceInputButton.focusLocate.inButton;
		private bool _contentLoaded;
		public event VoiceInputButton.VoiceButtonFocusFieldChange OnFocusFieldChange;
		public VoiceInputButton()
		{
			this.InitializeComponent();
		}
		protected override void OnManipulationDelta(ManipulationDeltaEventArgs manipulationDeltaEventArgs_0)
		{
			base.OnManipulationDelta(manipulationDeltaEventArgs_0);
			this.deltaPoint.set_X(manipulationDeltaEventArgs_0.get_ManipulationOrigin().get_X() + manipulationDeltaEventArgs_0.get_DeltaManipulation().get_Translation().get_X());
			this.deltaPoint.set_Y(manipulationDeltaEventArgs_0.get_ManipulationOrigin().get_Y() + manipulationDeltaEventArgs_0.get_DeltaManipulation().get_Translation().get_Y());
			if (this.CheckNowInButtonField(this.deltaPoint))
			{
				if (this.nowLocate != VoiceInputButton.focusLocate.inButton)
				{
					this.nowLocate = VoiceInputButton.focusLocate.inButton;
					if (this.OnFocusFieldChange != null)
					{
						this.OnFocusFieldChange(this, new FocusFieldArgs(this.nowLocate));
						return;
					}
				}
			}
			else
			{
				if (this.CheckNowInCancelField(this.deltaPoint))
				{
					if (this.nowLocate != VoiceInputButton.focusLocate.inCancel)
					{
						this.nowLocate = VoiceInputButton.focusLocate.inCancel;
						if (this.OnFocusFieldChange != null)
						{
							this.OnFocusFieldChange(this, new FocusFieldArgs(this.nowLocate));
							return;
						}
					}
				}
				else
				{
					if (this.nowLocate != VoiceInputButton.focusLocate.inOther)
					{
						this.nowLocate = VoiceInputButton.focusLocate.inOther;
						if (this.OnFocusFieldChange != null)
						{
							this.OnFocusFieldChange(this, new FocusFieldArgs(this.nowLocate));
						}
					}
				}
			}
		}
		private bool CheckNowInButtonField(Point nowPoint)
		{
			double x = nowPoint.get_X();
			double y = nowPoint.get_Y();
			return x >= this.buttonfieldStart.get_X() && y >= this.buttonfieldStart.get_Y() && x <= this.buttonfieldStart.get_X() + this.buttonWidth && y <= this.buttonfieldStart.get_Y() + this.buttonHeight;
		}
		private bool CheckNowInCancelField(Point nowPoint)
		{
			double x = nowPoint.get_X();
			double y = nowPoint.get_Y();
			return x >= this.cancelFieldStart.get_X() && y >= this.cancelFieldStart.get_Y() && x <= this.cancelFieldStart.get_X() + this.cancelWidth && y <= this.cancelFieldStart.get_Y() + this.cancelHeight;
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/Chat/VoiceInputButton.xaml", 2));
		}
	}
}
